package com.hzhjhh.enums;

import java.util.Optional;

import org.apache.commons.lang3.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 会员卡等级枚举
 * 
 * @author 12083
 *
 */
@Getter
@AllArgsConstructor
public enum VipCardLevelEnum {

	SUPER_MANAGE("SUPER_MANAGE", "超级管理员"),
	CASHIER("CASHIER", "收银员"),
	VIP_GOLD("VIP_GOLD", "黄金会员"),
	VIP_SILVER("VIP_SILVER", "白银会员"),
	VIP_BRONZE("VIP_BRONZE", "青铜会员"),
	;
	
	/**
	 * 会员卡等级编码
	 */
	private final String code;
	/**
	 * 会员卡等级说明
	 */
	private final String desc;
	
	/**
	 * 根据code获取枚举
	 */
	public static Optional<VipCardLevelEnum> getEnumByCode(String code) {
		if (StringUtils.isBlank(code)) {
			return Optional.empty();
		}
		for (VipCardLevelEnum enums : VipCardLevelEnum.values()) {
			if (StringUtils.equals(code, enums.code)) {
				return Optional.of(enums);
			}
		}
		return Optional.empty();
	}
}
